/*
* ============================================================================
*  Name        : sea_stack.h
*  Part of     : Finite state machine utilities
*  Description : 
*  Version     : %version: %
*  
*
* ============================================================================
*/
/**
 * @file sea_stack.h
 * @brief
 * @ref sea::Link based @ref sea::Stack
 *
 * @ingroup AssociationUtilities
 */
#if !defined( __sea_stack_h__ )
#define __sea_stack_h__

#include "sea_list.h"

namespace sea
{
    /** 
     * @class Stack sea_stack.h "sea_stack.h"
     * @brief Stack implementation. List derivative.\b Thread \b safe.
     *
     * @ingroup AssociationUtilities
     */
    class Stack: public List
    {
    public:
        Stack( Association id = 0 ): List( id ) { }
        ~Stack( ){ clear( ); }

        /**
         * Push element into the stack
         *
         * @param obj     pointer to an object
         *
         * @return @li TRUE     On success
         * @return @li FALSE    Otherwise.
         */
        bool push( Object* obj );
        bool push( ref< >& obj ){ return push( obj.get( ) ); }

        /**
         * Pops element from the stack
         *
         * @return pointer to an object
         */
        sea::ref< > pop( );

        /**
         * Peaks element from the stack. Does not remove object from the stack
         *
         * @return pointer to an object
         */
        sea::ref< > peak( ){ return get_first( ); }

        /**
         * Checks if stack is empty
         *
         * @return TRUE     If it does
         */
        bool is_empty( ) { return size( ) == 0; }
    };
}

#endif // #if !defined( __sea_stack_h__ )
